<template>
    <el-container class="bg-white" :style="{height: h + 'px'}">
        <el-header class="image-header">
            <el-button type="primary" size="small" @click="hanleOpenCreate">新增图片分类</el-button>
            <el-button type="warning" size="small" @click="handleOpenUpload">传图片</el-button>
        </el-header>
        <el-container>
            <ImageAside ref="ImageAsideRef" @change="handleAsideChange" />
            <ImageMain ref="ImageMainRef" />
        </el-container>
    </el-container>
</template>
<script setup>
import { ref } from 'vue'
import ImageAside from '~/components/ImageAside.vue'
import ImageMain from '~/components/ImageMain.vue'
const windowHeight = window.innerHeight || document.body.clientHeight
const h = windowHeight - 64 - 44 - 40

const ImageAsideRef = ref(null)
const ImageMainRef = ref(null)
// 获取到子组件，调用子组件暴露出来的方法hanleCreate() 使抽屉显示
const hanleOpenCreate = () => ImageAsideRef.value.handleCreate()

const handleAsideChange = (image_class_id) => {
    // 绑定自定义事件，得到当前左边的图库分类的id,传给父组件，再通过调用子组件暴露出来的方法，将id传进去，调用另一个组件的内部的方法
    ImageMainRef.value.loadData(image_class_id)
}

const handleOpenUpload = () => ImageMainRef.value.openUploadFile()

</script>

<style>
.image-header {
    border-bottom: 1px solid #eeee;
    @apply flex items-center;
}
</style>